package cn.dm.cotroller;

import cn.dm.service.AlipayService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping(value = "/pay")
public class AlipayController {
    @Resource
    private AlipayService alipayService;

    /**
     *
     * @param response
     * @param orderNo 订单号
     * @param totalAmount 订单总价格
     * @param itemName 商品名称
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getPay",method = RequestMethod.POST)
    public void getPay(HttpServletResponse response,String orderNo,String totalAmount,String itemName) throws Exception{
        String page=alipayService.goPay(orderNo,totalAmount,itemName);
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().println(page);
        response.getWriter().flush();
        response.getWriter().close();
    }
}
